<template>
  <div id="app">
    <myheader v-if="$store.state.winWidth > 768" v-show="path && path!='feadback' && !path.includes('job')"></myheader>
    <mobheader v-else  v-show="path && !path.includes('job')"></mobheader>
    <router-view :class="{marTop:path=='contactUs' || path== 'news' || path=='afterSale' || path=='guide'}"></router-view>
    <myfooter v-if="$store.state.winWidth > 768" v-show="path && path!='feadback' && !path.includes('job')"></myfooter>
    <mobfooter v-else  v-show="path && !path.includes('job')"></mobfooter>
  </div>
</template>

<script>
import myheader from "@/components/Header.vue"
import myfooter from "@/components/Footer.vue"
import mobheader from "@/components/mobHeader.vue"
import mobfooter from "@/components/mobFooter.vue"
export default {
  name: 'App',
  components: {
    myheader,
    myfooter,
    mobheader,
    mobfooter
  },
  data() {
    return {
        
    }
  },
  computed:{
path(){
  console.log(this.$route.name);
  
  return this.$route.name
}
  },
  mounted() {
    this.getNavs()
    this.getOption()
    this.$store.commit('setWidth', window.innerWidth)
    this.$store.commit('setScroll', window.scrollY)
    window.addEventListener('resize', this.handleResize)
    window.addEventListener('scroll', this.handleScroll)


  },
  beforeDestroy() {
    window.removeEventListener('resize', this.handleResize)
    window.removeEventListener('scroll', this.handleScroll)
  },
  methods: {
    handleResize() {
      if (window.innerWidth > 768) {
        document.body.style.overflow = ''
      }
    },
    handleScroll() {
      this.$store.commit('setScroll', window.scrollY)
    },
    getNavs() {
      this.$api.getNavs().then(res => {
        if (res.code == 1) {
          this.$store.commit('setMenu', {
            ddsh: res.data.ddsh,
            ddsl: res.data.ddsl,
            fgkj: res.data.fgkj,
            fwzc: res.data.fwzc,
            gywm: res.data.gywm,
            list: res.data.list
          })

        }
      })
    },
    getOption() {
      this.$api.getOption({
        type: "kf_phone,kf_logo,kf_worktime,site_copyright,site_icp,main_logo,second_logo,site_name,site_analytics,zp_logo,zp_company,zp_intro,zp_title,zp_content,site_analytics,city"
      }).then(res => {
        if (res.code == 1) {
          this.$store.commit('setdataInfo', res.data)
          document.title = res.data.site_name

        }
      })
    },
  },
}
</script>

<style scoped>

</style>
